import java.util.Scanner;

public class StringDemo1 {
    public static void main(String[] args) {
        //定义正确的用户名和密码;
        String rightUsername = "zhangshan";
        String rightPassword = "123456";
        //模拟用户登录
        //用户输入用户名和密码



        for (int i = 0; i < 3; i++) {
            //总共有三次机会
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入用户名");
            String username = sc.next();
            System.out.println("请输入密码");
            String password = sc.next();
            if (username.equals(rightUsername) && password.equals(rightPassword)) {
                System.out.println("登录成功");
                break;
            }else{
                System.out.println("登录失败,用户名或密码错误");
                System.out.println("您还有"+(2-i)+"次机会");
                System.out.println("请重新输入");
                System.out.println("________");
            }



        }



    }
}
